<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue应用</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>

<body>
    <div id="Application">
        <button @click="click">单击</button>
    </div>

    <script>
        const appData = {
            data: {
                count: 0
            }
        }
        
        const App = Vue.createApp({
            data() {
                return appData
            },
            computed: {
                countString: {
                    get() {
                        return this.count + "次"
                    }
                }
            },
            methods: {
                click() {

                    // 下面的语句是不能访问到这个变量的
                    // console.log(this.count)
                    this.data.count += 1
                    console.log(this.data.count)
                }
            },
            watch: {
                data: {
                    handler(value, oldValue) {
                        // TODO value是一个代理，怎么获取这里面的count值
                        console.log(value, oldValue)
                        // console.log(value.Target.count)
                        // console.log(oldValue.Target.count)
                    },
                    deep: true
                }

            }
        })
        App.mount("#Application") 
    </script>
</body>

</html>